import 'package:chat_app_project/dao/follow_dao.dart';
import 'package:flutter/material.dart';
import 'package:getwidget/components/button/gf_button.dart';
import 'package:getwidget/components/list_tile/gf_list_tile.dart';
import 'package:getwidget/size/gf_size.dart';

import '../../../models/const.dart';
import '../../../models/followers_entity.dart';

class Followers extends StatefulWidget {
  const Followers({super.key});

  @override
  State<Followers> createState() => _FollowersState();
}

class _FollowersState extends State<Followers> {
  List<FollowersEntity> users = [];

  @override
  void initState() {
    super.initState();
    FollowDao.followList({"memberId": UserInfo.uid}).then((value) {
      value.data["list"].forEach((item) {
        users.add(FollowersEntity.fromJson(item));
      });
      setState(() {});
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('关注列表'),
      ),
      body: ListView.builder(
        itemCount: users.length,
        itemBuilder: (context, index) {
          return GFListTile(
            titleText: users[index].nickName,
            avatar: CircleAvatar(
              radius: 20,
              backgroundImage: NetworkImage(users[index].avatar),
            ),
            icon: GFButton(
              onPressed: () {},
              text: users[index].followStatus == 1? "关注" : "取消关注",
              size: GFSize.SMALL,
            ),
          );
        },
      ),
    );
  }
}
